//
//  AudioPlayer.h
//  RNRecorder
//
//  Created by GJS on 2018/8/22.
//  Copyright © 2018年 Facebook. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

#import "BufferManager.h"
#import "DCRejectionFilter.h"
#import "AudioPlayDelegate.h"

@interface AudioPlayer : NSObject {
    
    AudioUnit               _rioUnit;
    BufferManager*          _bufferManager;
    DCRejectionFilter*      _dcRejectionFilter;
    BOOL                    _audioChainIsBeingReconstructed;
}

@property (nonatomic, weak) id<AudioPlayDelegate> delegate;

@property (nonatomic, assign) BOOL muteAudio;
@property (nonatomic, assign) BOOL disableOutput;
@property (nonatomic, assign, readonly) BOOL audioChainIsBeingReconstructed;

- (BufferManager*)  getBufferManagerInstance;
- (OSStatus)        startIOUnit;
- (OSStatus)        stopIOUnit;
- (double)          sessionSampleRate;

- (instancetype)initWithUrl:(NSURL *)url;
- (BOOL)openWithUrl:(NSURL *)url;
- (BOOL)open;
- (void)play;
- (void)pause;
- (void)stop;
- (double)getCurrentTime;

@end
